-
Notifications
You must be signed in to change notification settings - Fork 178
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for Device Information Spec #287
Add support for Device Information Spec #287
Conversation
cc @Billy99 |
e78212b
to
13ccdb4
Compare
With this change, having the following pools:
I get the following files:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/lgtm
None of the comments are real issues, just nits. I tested with the version just before the PR was created and worked fine with pending device-info Multus PR. The PR comment indicated that only the mandatory fields were filled in. Is that the plan for the final PR or just because this is still [WIP] (just wondering, not pressuring to fill in the rest)?
13ccdb4
to
686f91b
Compare
I was thinking in pushing the mandatory fields first (pci-address) mainly because how the rest of the device info is handled is being discussed in #281 |
3db1cc4
to
eefbb48
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like CI failed, is it because due to not using 1.15 golang version?
eefbb48
to
5d0b4fb
Compare
I'm not sure why it's failing. I'm looking into it but it's taking some time since I get errors in Travis that I cannot reproduce locally. |
5d0b4fb
to
1abbad7
Compare
@zshi-redhat, the CI instability issues I was facing are now solved. PTAL |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/LGTM. Performed as expected.
volumes: | ||
- name: devicesock | ||
hostPath: | ||
path: /var/lib/kubelet/ | ||
- name: log | ||
hostPath: | ||
path: /var/log | ||
- name: device-info | ||
hostPath: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do you need to specify
DirectoryOrCreate
type ?
what if the path does not exist on the host ? will it be created ?
https://kubernetes.io/docs/concepts/storage/volumes/#hostpath
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not see any error when I tested it. The nad library would take care of creating the directory so from a DevicePlugin perspective, it should not care. However, it's not a bad idea to add that type flag.
Thanks
Save the deviceInfo files on server startup and remove them on server clean up. Signed-off-by: Adrian Moreno <[email protected]>
Signed-off-by: Adrian Moreno <[email protected]>
Signed-off-by: Adrian Moreno <[email protected]>
Move the creation of the mocked resourcePool out of BeforeEach because it is used in a goroutine (the one that calls server.Stop()) and so having a unique reference would cause race-conditions. Signed-off-by: Adrian Moreno <[email protected]>
1abbad7
to
61dad28
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO changes are good. I also tested the change locally to get a better feel for the new behaviour.
Are you planning to add unit test for {Store/Clean}DeviceInfoFile` ?
nadutils
can be put behind an interface to allow mocking
p.s
regarding my last comment indeed it seems to work when DirectoryOrCreate
is not specified.
but no harm in keeping it IMO.
The current unit test verifies that Store/CleanDeviceInfoFile are called but not what it does internally
Good idea, I did not think of that option. So we would have to:
Are we good with this approach? |
@martinkennelly, @adrianchiris, Talking to @zshi-redhat, we considered an alternative approach in order to make the unit tests cleaner: make What do you think? |
Generally Yes from my POV, See my comments below on the proper singleton bit.
resourceFactory is a signleton today, its I think having resourceFactory instance as a member of other constructs follows the pattern of dependency injection, to help with unit tests and ease refactoring/replacing existing implementations of different interfaces. what you propose kinda deviates from that path. I think the refactor for If you think adding unit-test in the current state of code requires alot of code changes im fine with having it as a separate PR. |
I don't think that's really the case (although the intention does seem that one): sriov-network-device-plugin/pkg/factory/factory.go Lines 39 to 49 in 89b9bc9
#300 created
I don't think it's a a lot of code, it just requires modifying the |
you are right ! there is no assignment to
Thanks!
IMO its a reasonable change to facilitate UT of the added methods |
@adrianchiris PTAL at the last 3 commits (the rest of the PR unchanged) |
CI failed because |
2601529
to
ebfe3c3
Compare
ebfe3c3
to
fe69556
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @amorenoz !!
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks for the rework / noticing the singleton issue.
In order to enable mocking the functions form k8snetworkplumbingwg/network-attachment-definition-client, required for unit testing, create a nadutils wrapper interface and the implementation. Use the resourceFactory to create instances of the implementation that lives in netdevice. Signed-off-by: Adrian Moreno <[email protected]>
In order to be able to unit test functions that use nadutils, use the newly created interface in the netResourcePool. Signed-off-by: Adrian Moreno <[email protected]>
Two unit tests are added: netResourcePool_test verifies that the appropriate nadutils functions are called with the correct arguments on netResourcePool.{Store,Clean}DeviceInfoFile() server_test.go verifies that the resourcePool.{Store,Clean}DeviceInfoFile() functions are actually called when the server starts and stops. Signed-off-by: Adrian Moreno <[email protected]>
fe69556
to
7b8da30
Compare
As per the device-info specification, save the device information in a file using github.com/k8snetworkplumbingwg/network-attachment-definition-client
utility functions.
As per the design decisions made: Added the create/clean functions to the ResourcePool Interface and implement them in the netResourcePool so that the entire device information can be accessed
Error handling:
For now, only add the mandatory fields.
Fixes: #286